Skip to content

fix(vscode): frontmatter diagnostic + icon (v0.1.2)#31

Merged
SingleSourceStudios merged 2 commits intomainfrom
fix/vscode-v0.1.2
Apr 18, 2026
Merged

fix(vscode): frontmatter diagnostic + icon (v0.1.2)#31
SingleSourceStudios merged 2 commits intomainfrom
fix/vscode-v0.1.2

Conversation

@SingleSourceStudios
Copy link
Copy Markdown
Collaborator

@SingleSourceStudios SingleSourceStudios commented Apr 18, 2026

What

Ships VSCode extension v0.1.2 (already published to Marketplace).

Changes

Bug fix: false-positive frontmatter diagnostic

String.prototype.search(regex, startIndex) silently ignores its second argument, so frontmatterEnd was always equal to frontmatterStart — the substring for the required-field check was empty, and every valid .logic.md file got three warnings (spec_version, name, reasoning missing).

Replaced with a /g-flagged regex and two .exec() calls, which correctly advances past the first match via lastIndex. Also tightened the pattern to /^---\s*$/gm so only full-line --- delimiters match.

Icon

Added 256×256 marketplace icon (editors/vscode/icon.png) referenced from package.json.

Version

0.1.10.1.2. Already published via vsce publish.

Test plan

  • Opened hello-agent.logic.md generated by @logic-md/cli init — no false-positive diagnostics after fix.
  • Marketplace listing shows new icon on v0.1.2.

Summary by cubic

Fixes frontmatter diagnostics for .logic.md by only treating --- at the first line as frontmatter, removing false warnings for spec_version, name, and reasoning and ignoring later --- blocks. Adds a 256×256 marketplace icon and bumps the VS Code extension to v0.1.2.

Written for commit 5184ff8. Summary will update on new commits.

Summary by CodeRabbit

  • Chores

    • Bumped extension version to 0.1.2.
    • Added extension icon for improved visibility.
  • Bug Fixes

    • Enhanced frontmatter delimiter detection for more reliable document validation.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

The VS Code extension receives a minor version bump to 0.1.2, with an icon metadata field added to the manifest. Additionally, the frontmatter delimiter detection logic is refactored to use global multiline regex patterns with repeated exec() calls instead of String.search().

Changes

Cohort / File(s) Summary
Manifest Updates
editors/vscode/package.json
Version bumped from 0.1.1 to 0.1.2; new icon field added pointing to icon.png.
Delimiter Detection Refactoring
editors/vscode/src/extension.ts
Frontmatter delimiter detection logic updated from String.prototype.search() to global multiline regex (/^---\s*$/gm) with repeated exec() calls for computing opening and closing delimiter indices.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

vscode-extension

Poem

A hop through versions, one-two now shown,
With icon gleaming, brightly known,
Delimiters dance where regex flows,
The little extension grows and grows! 🐰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: a frontmatter diagnostic fix, icon addition, and version bump to v0.1.2.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description comprehensively covers all changes, provides context on the bug fix, and includes a test plan for verification.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vscode-v0.1.2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
editors/vscode/src/extension.ts (1)

87-93: Fix looks correct; consider guarding against non-leading frontmatter.

The /gm + sequential exec() approach correctly advances lastIndex and resolves the original search(regex, startIndex) bug. One pre-existing edge case worth noting (not introduced here): frontmatterStart isn't required to be 0, so a document with a stray --- block later in the file would be treated as frontmatter. If you want to tighten this, anchor the first match to the document start:

Optional hardening
-	const fmRegex = /^---\s*$/gm;
-	const firstMatch = fmRegex.exec(text);
-	const frontmatterStart = firstMatch ? firstMatch.index : -1;
-	const secondMatch = firstMatch ? fmRegex.exec(text) : null;
-	const frontmatterEnd = secondMatch ? secondMatch.index : -1;
+	const fmRegex = /^---\s*$/gm;
+	const firstMatch = fmRegex.exec(text);
+	// Frontmatter must be the very first line of the document.
+	const frontmatterStart = firstMatch && firstMatch.index === 0 ? 0 : -1;
+	const secondMatch = frontmatterStart === 0 ? fmRegex.exec(text) : null;
+	const frontmatterEnd = secondMatch ? secondMatch.index : -1;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@editors/vscode/src/extension.ts` around lines 87 - 93, The current code
treats any `---` anywhere as frontmatter; guard by ensuring the first
`fmRegex.exec(text)` match is at the document start (index 0) before treating it
as frontmatter: after computing `firstMatch` (from `fmRegex.exec(text)`), check
`firstMatch.index === 0` (or equivalently verify `frontmatterStart === 0`) and
only then call `fmRegex.exec(text)` again to find the closing delimiter and set
`frontmatterStart`/`frontmatterEnd`; otherwise treat as no frontmatter. This
uses the existing symbols `fmRegex`, `firstMatch`, `frontmatterStart`, and the
second `exec()` call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@editors/vscode/src/extension.ts`:
- Around line 87-93: The current code treats any `---` anywhere as frontmatter;
guard by ensuring the first `fmRegex.exec(text)` match is at the document start
(index 0) before treating it as frontmatter: after computing `firstMatch` (from
`fmRegex.exec(text)`), check `firstMatch.index === 0` (or equivalently verify
`frontmatterStart === 0`) and only then call `fmRegex.exec(text)` again to find
the closing delimiter and set `frontmatterStart`/`frontmatterEnd`; otherwise
treat as no frontmatter. This uses the existing symbols `fmRegex`, `firstMatch`,
`frontmatterStart`, and the second `exec()` call.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 378033f0-c4d2-47d0-8b23-9d795937264b

📥 Commits

Reviewing files that changed from the base of the PR and between 8c83e18 and f71a9de.

⛔ Files ignored due to path filters (2)
  • editors/vscode/icon.png is excluded by !**/*.png
  • editors/vscode/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • editors/vscode/package.json
  • editors/vscode/src/extension.ts

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Only treat --- as frontmatter when it appears at index 0. Prevents stray
--- blocks later in the file (markdown horizontal rules) from being
misidentified as frontmatter delimiters. Addresses CodeRabbit nitpick on #31.
@SingleSourceStudios SingleSourceStudios merged commit 6abf9a7 into main Apr 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant